<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
  </head>
  
  <body>
  <label>管理员登陆</label>
  <br>
   <label>用户名</label> <input type="text" id="name" value=""/>
   <br>
   <label>密码</label><input type="text" id="pwd" value=""/>
   <br>
   <button onclick="but_login()">登陆</button>
  </body>
  <script type="text/javascript">
  function but_login(){
	  var loginUrl = '<%=basePath%>login/checkAdmin';
	  $.post(loginUrl,{
		  name:$('#name').val(),
		  pwd:$('#pwd').val()
	  },function(data,status){
		  var result = eval('(' + data + ')');
		  alert(result);
		  if(result=='登陆成功'){
		  location.href ='adminAddUser.jsp';
		  }else{
			  window.location.reload();
		  }
	  });
  }
  </script>
</html>
